import type { TableProps } from "tdesign-vue-next";

import { getValueBySelectData } from "@/utils/tools";
import { STATUS_DATA } from "@/common/constants";

// 表格列配置
export const tableColumns = [
  {
    colKey: "providerNo",
    title: "供应商编号",
    width: 200
  },
  {
    colKey: "name",
    title: "供应商名称",
    width: 220,
    filter: {
      type: "input",
      resetValue: "",
      // 按下 Enter 键时也触发确认搜索
      confirmEvents: ["onEnter"],
      showConfirmAndReset: true
    }
  },
  {
    colKey: "nickName",
    title: "供应商简称",
    width: 220,
    filter: {
      type: "input",
      resetValue: "",
      // 按下 Enter 键时也触发确认搜索
      confirmEvents: ["onEnter"],
      showConfirmAndReset: true
    }
  },
  {
    colKey: "englishName",
    title: "英文名称",
    width: 220
  },
  {
    colKey: "countryName",
    title: "经营国别",
    width: 220
  },
  {
    colKey: "province",
    title: "地区",
    width: 220
  },
  {
    colKey: "status",
    title: "状态",
    width: 150,
    filter: {
      type: "multiple",
      resetValue: null,
      list: [{ label: "全选", checkAll: true }, ...STATUS_DATA],
      // 是否显示重置取消按钮，一般情况不需要显示
      showConfirmAndReset: true
    },
    cell: (h, { row }) => {
      return getValueBySelectData(STATUS_DATA, row.status);
    }
  }
] as TableProps["columns"];
